<?php

class MyInfoPanel extends Qpanel {


    //Controls


    //Template
    protected $strTemplate;
    public $strHtml;

    public function __construct($objParentObject,  $strControlId = null) {
        // Call the Parent
        try {
            parent::__construct($objParentObject, $strControlId);
        } catch (QCallerException $objExc) {
            $objExc->IncrementOffset();
            throw $objExc;
        }

        // Setup Template
        $this->strTemplate = __DOCROOT__. __MY__ .  '/tpl/qpanel.tpl.php';
        $this->strHtml="";

        $this->strHtml  .=  "Welecome <font color='red'>" . $_SESSION[_SV_PERM_][_SV_PERM_USERNAME_] .  " (".
                $_SESSION[_SV_PERM_][_SV_PERM_ID_] . ")";
        $this->strHtml  .= "</font>.<br>";
        $this->strHtml  .= "Admin : <font color='red'>";

        if ( $_SESSION[_SV_PERM_][_SV_PERM_Admin_Role_] == true ) {
            $this->strHtml  .=  "YES";
        }
        else {
            $this->strHtml  .=  "NO";
        }
        $this->strHtml  .=  "</font><br><br><br>";

        $this->strHtml  .=  "Primary Role: <font color='red'>". $_SESSION[_SV_PERM_][_SV_PERM_PRole_];
        $this->strHtml  .=  "(" . $_SESSION[_SV_PERM_][_SV_PERM_PRole_]->Id. ")</font>";
        $this->strHtml  .=  "<br>Effective Role(s):<br>";

        foreach ($_SESSION[_SV_PERM_][_SV_PERM_ERole_] as $role) {
            $this->strHtml  .=  "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&bull;<font color='red'>". $role . "(". $role->Id. ")</font>";
        }

        $a = Org::LoadArrayMyOrgPRole();
        $this->strHtml  .=  "<h4>My Schools (Primary Role) :</h4>";
        foreach ($a as $x) {
            $this->strHtml  .=  "&bull;". $x->Name. "&nbsp;<font color='red'>" . "(". $x->Id. ")</font>" ." <br>";
        }

        $a = Org::LoadArrayMyOrgERoles();
        $this->strHtml  .=  "<h4>My Schools (Effective Roles) :</h4>";
        foreach ($a as $x) {
            $this->strHtml  .=  "&bull;". $x->Name . "&nbsp;<font color='red'>" . "(". $x->Id. ")</font>" . "<br>";
        }

        $a = Org::LoadArrayMyOrgAllRoles();
        $this->strHtml  .=  "<h4>My Schools (All Roles) :</h4>";
        foreach ($a as $x) {
            $this->strHtml  .=  "&bull;". $x->Name . "&nbsp;<font color='red'>" . "(". $x->Id. ")</font>"." <br>";
        }


        $this->strHtml  .=  "<h4>I Manage these Schools (Primary Role) :</h4>";
        $a = Org::LoadArrayByRoleAsMano( $_SESSION[_SV_PERM_][_SV_PERM_PRole_]->Id);
        foreach ($a as $x) {
            $this->strHtml  .=  "&bull;". $x->Name . "&nbsp;<font color='red'>" . "(". $x->Id. ")</font>"  ." <br>";
        }

        $this->strHtml  .=  "<h4>Schols I have permission to :</h4>";
        $a = Org::LoadArrayMyOrgAllPerm();
        foreach ($a as $x) {
            $this->strHtml  .=  "&bull;". $x->Name. "&nbsp;<font color='red'>" . "(". $x->Id. ")</font>" ." <br>";
        }
        

        $this->strHtml  .=  "<h4>I Manage these Roles :</h4>";
        $a = Role::Load( $_SESSION[_SV_PERM_][_SV_PERM_PRole_]->Id );
        $a= $a->GetRoleAsManrArray();
        foreach ($a as $x) {
            $this->strHtml  .=  "&bull;". $x->Name ." <br>";
        }


        $this->strHtml  .=  "<h4>I Managed  by these Roles :</h4>";
        $a = Role::Load( $_SESSION[_SV_PERM_][_SV_PERM_PRole_]->Id );
        $a= $a->GetParentRoleAsManrArray();
        foreach ($a as $x) {
            $this->strHtml  .=  "&bull;". $x->Name ." <br>";
        }



        $this->strHtml  .= "Session Time out : ".  ini_get('session.gc_maxlifetime');
    }

    public function Validate() {
        $blnToReturn = true;


        return $blnToReturn;
    }




}
?>


